//
//  InformationListViewController.m
//  TeamInformatization
//
//  Created by bigger on 2019/3/31.
//  Copyright © 2019年 SPIC. All rights reserved.
//

#import "InformationListViewController.h"
#import "InformationListHeadView.h"
#import "InformationListTableviewCell.h"
#import "InformationData.h"

@interface InformationListViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tablev;
@property (nonatomic, strong) InformationListHeadView *headv;
@property (nonatomic, strong) NSMutableArray *informationListArray;

@end

@implementation InformationListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.navigationItem.title = @"文档资料";
    [self showTitleBarWithTitle:@"文档资料" leftButtonStyle:Base_NavigationBar_Back rightButtonStyle:Base_NavigationBar_None];
    // UI
    [self loadShowViews];
    
    // Data
    [self requestInfoListData];
}

- (void)requestInfoListData
{
    // 初始数据
    self.informationListArray = [NSMutableArray array];
    for (int i = 0; i < 10; i++) {
        InformationData *data = [[InformationData alloc] init];
        data.title = @"内蒙古公司安全生产基础巩固年专项检查实施";
        data.subtitle = @"部署2019年工作重点部署2019年工作";
        [self.informationListArray addObject:data];
    }
    [_tablev reloadData];
}

- (void)loadShowViews
{
    [self.view addSubview:self.headv];
    [self.view addSubview:self.tablev];
}
-(InformationListHeadView *)headv {
    if (!_headv) {
        _headv = [[InformationListHeadView alloc] init];
        _headv.frame = CGRectMake(0, kNavigationBarHeight, kScreenWidth, 107);
        WS(weakSelf);
        weakSelf.headv.searchBlock = ^(NSString * _Nonnull searchStr) {
            NSLog(@"%@", searchStr);
        };
    }
    return _headv;
}
-(UITableView *)tablev {
    if (!_tablev) {
        _tablev = [[UITableView alloc] initWithFrame:CGRectMake(0,kNavigationBarHeight+107+10, kScreenWidth, kScreenHeight -(kNavigationBarHeight+107+10)) style:UITableViewStylePlain];
        [_tablev registerClass:[InformationListTableviewCell class] forCellReuseIdentifier:@"InformationListTableviewCell"];
        _tablev.delegate = self;
        _tablev.dataSource = self;
        _tablev.backgroundColor = [UIColor whiteColor];
        _tablev.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
        [_tablev setSeparatorInset:UIEdgeInsetsMake(0, 107*kScaleWidth, 0, 0)];
        _tablev.showsVerticalScrollIndicator = NO;
    }
    return _tablev;
}

#pragma mark - TableViewDelegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 125;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    InformationListTableviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"InformationListTableviewCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[InformationListTableviewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"InformationListTableviewCell"];
    }
    
//    [cell setShowViewCellWithData:_informationListArray[indexPath.row]];
    
    return cell;
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

}

#pragma mark -返回
-(void)baseNavigationBarLeftButtonClick:(UIButton *)button
{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
